﻿// -----------------------------------------------------------------------
// <copyright file="ISubscriptionService.cs" company="Zen Design Corp">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Zen.BlackBerry.Subscription
{
	using System;
	using System.Collections.Generic;
	using Zen.BlackBerry.Subscription.Count;
	using Zen.BlackBerry.Subscription.Sync;
	using Zen.BlackBerry.Subscription.Web;

	/// <summary>
	/// Data access interface for subscribers.
	/// </summary>
	public interface ISubscriptionRepository
	{
		/// <summary>
		/// Deletes an inactive subscription from storage.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		void DeleteInactiveSubscription(string pushApplicationId, string subscriberId);

		/// <summary>
		/// Deletes all the subscriptions from storage (and potentially the cache) for a push application entirely and permanently.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		void DeleteSubscriptions(string pushApplicationId);

		/// <summary>
		/// Finds a list of subscribers with the specified address and the specified subscriber id and NOT the specified status.
		/// </summary>
		/// <param name="address">The address.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAddressAndIdAndNotStatus(string address, string subscriberId, SubscriberStatus status);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified address and NOT the specified subscriber id and NOT the specified status.
		/// </summary>
		/// <param name="address">The address.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAddressAndNotIdAndNotStatus(string address, string subscriberId, SubscriberStatus status);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified push application id.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAppId(string pushApplicationId, int startIndex, int endIndex);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified push application id and address.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="address">The address.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAppIdAndAddress(string pushApplicationId, string address);
		   
		/// <summary>
		/// Finds the subscriber with the specified id and push application id.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <returns>A <see cref="Subscriber"/> object.</returns>
		Subscriber FindByAppIdAndId(string pushApplicationId, string subscriberId);

		/// <summary>
		/// Finds the subscriber with the specified id and push application id.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <returns>A <see cref="SubscriberPartial"/> object.</returns>
		SubscriberPartial FindByAppIdAndIdPartial(string pushApplicationId, string subscriberId);

		/// <summary>
		/// Finds a list of subscribers for the given push application id that are in the specified subscriber id list with the specified status.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="subscriberIds">The subscriber ids.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAppIdAndIdsAndStatus(string pushApplicationId, IEnumerable<string> subscriberIds, SubscriberStatus status);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified push application id and status.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="status">The status.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAppIdAndStatus(string pushApplicationId, SubscriberStatus status, int startIndex, int endIndex);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified push application id and type.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="type">The type.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAppIdAndType(string pushApplicationId, SubscriberType type, int startIndex, int endIndex);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified push application id, type, and status.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="type">The type.</param>
		/// <param name="status">The status.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByAppIdAndTypeAndStatus(string pushApplicationId, SubscriberType type, SubscriberStatus status, int startIndex, int endIndex);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified id.
		/// </summary>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindById(string subscriberId);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified id and NOT the specified status.
		/// </summary>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByIdAndNotStatus(string subscriberId, SubscriberStatus status);
		   
		/// <summary>
		/// Finds a list of subscribers with the specified id and status.
		/// </summary>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByIdAndStatus(string subscriberId, SubscriberStatus status); 
		 
		/// <summary>
		/// Finds a list of subscribers whose id contains the given subscriberIdPattern.
		/// </summary>
		/// <param name="subscriberIdPattern">The subscriber id pattern.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns>
		/// An enumeration of <see cref="SubscriberPartial"/> corresponding to matching subscribers.
		/// </returns>
		IEnumerable<SubscriberPartial> FindByIdPattern(string subscriberIdPattern, int startIndex, int endIndex);

		
		/// <summary>
		/// Gets a count of the number of users of a push application (regardless of status) for each BlackBerry device model.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <returns>
		/// An enumeration of <see cref="DeviceModelCount"/> objects.
		/// </returns>
		IEnumerable<DeviceModelCount> GetDeviceModelCount(string pushApplicationId);
		 
		/// <summary>
		/// Gets a count of the number of users of a push application with a given status for each BlackBerry device model.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="DeviceModelCount"/> objects.
		/// </returns>
		IEnumerable<DeviceModelCount> GetDeviceModelCount(string pushApplicationId, SubscriberStatus status);
		 
		/// <summary>
		/// Gets a count of the number of users of a push application (regardless of status) for each OS version running on a BlackBerry device.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <returns>
		/// An enumeration of <see cref="OsVersionCount"/> objects.
		/// </returns>
		IEnumerable<OsVersionCount> GetOsVersionCount(string pushApplicationId);
		 
		/// <summary>
		/// Gets a count of the number of users of a push application with a given status for each OS version running on a BlackBerry device.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="status">The status.</param>
		/// <returns>
		/// An enumeration of <see cref="OsVersionCount"/> objects.
		/// </returns>
		IEnumerable<OsVersionCount> GetOsVersionCount(string pushApplicationId, SubscriberStatus status);
		 
		/// <summary>
		/// Gets a count of the number of users that had their subscriptions resumed for an application between the given date range.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="fromDate">From date.</param>
		/// <param name="toDate">To date.</param>
		/// <returns>
		/// A count of users who had their subscriptions resumed.
		/// </returns>
		int GetResumeCount(string pushApplicationId, DateTime fromDate, DateTime toDate);
		 
		/// <summary>
		/// Gets a count of all the subscribers in storage with the specified push application id.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <returns>A count of subscribers.</returns>
		int GetSizeByAppId(string pushApplicationId);
		
		/// <summary>
		/// Gets a count of all the subscribers in storage with the specified push application id and status.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="status">The status.</param>
		/// <returns>A count of subscribers.</returns>
		int GetSizeByAppIdAndStatus(string pushApplicationId, SubscriberStatus status);
		 
		/// <summary>
		/// Gets a count of all the subscribers in storage with the specified push application id and type.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="type">The type.</param>
		/// <returns>A count of subscribers.</returns>
		int GetSizeByAppIdAndType(string pushApplicationId, SubscriberType type);
		
		/// <summary>
		/// Gets a count of all the subscribers in storage with the specified push application id, type, and status.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="type">The type.</param>
		/// <param name="status">The status.</param>
		/// <returns>A count of subscribers.</returns>
		int GetSizeByAppIdAndTypeAndStatus(string pushApplicationId, SubscriberType type, SubscriberStatus status);
		 
		/// <summary>
		/// Gets a count of all the subscribers in storage whose id contains the given subscriberIdPattern.
		/// </summary>
		/// <param name="subscriberIdPattern">The subscriber id pattern.</param>
		/// <returns>A count of subscribers.</returns>
		int GetSizeByIdPattern(string subscriberIdPattern);
		
		/// <summary>
		/// Gets a count of the number of new subscribers to an application for a given date range.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="fromDate">From date.</param>
		/// <param name="toDate">To date.</param>
		/// <returns>A count of new subscribers.</returns>
		int GetSubscribeCount(string pushApplicationId, DateTime fromDate, DateTime toDate);
		 
		/// <summary>
		/// Gets a count of the number of users that had their subscriptions suspended for an application between the given date range.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="fromDate">From date.</param>
		/// <param name="toDate">To date.</param>
		/// <returns>
		/// A count of users who had their subscription suspended.
		/// </returns>
		int GetSuspendCount(string pushApplicationId, DateTime fromDate, DateTime toDate);
		 
		/// <summary>
		/// Gets a count of the number of users that unsubscribed from an application between the given date range.
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="fromDate">From date.</param>
		/// <param name="toDate">To date.</param>
		/// <returns>
		/// A count of users who unsubscribed.
		/// </returns>
		int GetUnsubscribeCount(string pushApplicationId, DateTime fromDate, DateTime toDate);

		/// <summary>
		/// Attempts to load a partial subscriber from the cache or from memory (for in-memory implementations).
		/// </summary>
		/// <param name="pushApplicationId">The push application id.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <returns>A <see cref="SubscriberPartial"/> object.</returns>
		SubscriberPartial LoadFromCache(string pushApplicationId, string subscriberId);

		/// <summary>
		/// Resubscribes a user to a push application.
		/// </summary>
		/// <param name="subscribeRequest">The subscribe request.</param>
		void Resubscribe(SubscribeRequest subscribeRequest);

		/// <summary>
		/// Resumes a user's subscription to a push application.
		/// </summary>
		/// <param name="resumeRequest">The resume request.</param>
		void Resume(ResumeRequest resumeRequest);
		 
		/// <summary>
		/// Subscribes a user to a push application.
		/// </summary>
		/// <param name="subscribeRequest">The subscribe request.</param>
		void Subscribe(SubscribeRequest subscribeRequest);
		 
		/// <summary>
		/// Suspends a user's subscription to a push application.
		/// </summary>
		/// <param name="suspendRequest">The suspend request.</param>
		void Suspend(SuspendRequest suspendRequest);
		 
		/// <summary>
		/// Unsubscribes a user from a push application.
		/// </summary>
		/// <param name="unsubscribeRequest">The unsubscribe request.</param>
		void Unsubscribe(UnsubscribeRequest unsubscribeRequest);
	}
}
